/**
 * @author yuyangyang
 * @time 2015/2/27
 */

define(function (require) {
    var angular = require('angular');

    angular.module('directives', [])

        .directive('loader', function ($log) {
            return {
                restrict: 'EA',
                template: '<div><input ng-model="username"><button ng-click="greet({name:username})">click</button></div>',
                //replace: true,
                //transclude: true,
                scope: {
                    greet: '&'
                },
                link: function (scope, element, attrs, controller) {

                }
                //compile: function (element, attrs, transclude) {
                //    var tpl = element.children().clone();
                //    for (var i = 0; i < attrs.alotofhello; i++) {
                //        element.append(tpl.clone());
                //    }
                //    $log.info('compile...')
                //    return function(){
                //        $log.info('link...')
                //    }
                //}
            }
        })


        .directive('ngbkFocus', function () {
            return {
                link: function (scope, element, attrs, controller) {
                    element[0].focus();
                }
            }
        })


        .directive('myDatepicker', function () {
            return {
                scope: {
                    callback: '&'
                },
                link: function (scope, element, attrs, controller) {
                    element.datepicker(function () {
                        scope.callback();
                    });
                }
            }
        })
});
